package com.jrtc.service.impl;

import com.jrtc.base.entity.bo.*;
import com.jrtc.base.entity.vo.CatchBallRecordVo;
import com.jrtc.dao.CatchBallRecordDao;
import com.jrtc.dao.CatchBallRecordDetailsDao;
import com.jrtc.dao.PatientDao;
import com.jrtc.dao.QuestionNaireDepartmentDao;
import com.jrtc.service.CatchBallRecordService;
import com.jrtc.service.DoctorService;
import com.jrtc.service.QuestionNaireDepartmentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.swing.*;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

@Service("questionNaireDepartmentService")
public class QuestionNaireDepartmentServiceImpl implements QuestionNaireDepartmentService {
    @Resource
    private QuestionNaireDepartmentDao questionNaireDepartmentDao;
    @Resource
    private DoctorService doctorService;

    /**
     * id获取问卷分类信息
     * */
    @Override
    public List<QuestionNaireDepartment> classification(Integer id) {
        List<QuestionNaireDepartment> classificationList = questionNaireDepartmentDao.classification(id);
        return classificationList;
    }

    /**
     * 医生添加问卷分类
     * */
    @Override
    public int insertClassification(HttpServletRequest request, QuestionNaireDepartment questionNaireDepartment) throws Exception {
        Doctor loginDoctor;
        try {
            loginDoctor = doctorService.getLoginDoctor(request);
        } catch (Exception e){
            throw new Exception("登录已过期");
        }

        questionNaireDepartment.setDoctorId(loginDoctor.getDoctorId());
        questionNaireDepartment.setCreationTime(new Date());
        int i = questionNaireDepartmentDao.insertClassification(questionNaireDepartment);
        return i;
    }
}